﻿@using Website.CRUDServices
@using Website.Models.Styling
@using Location = Website.Models.Domain.Location
@model Website.Models.ViewModels.ListView<ProjectMeeting>
@{
    this.ViewBag.Title = "Netværk";
    this.Layout = "~/Views/_Shared/_Layout.cshtml";
    
    var roles = this.ViewData["Roles"] as List<ProjectMeetingRole> ?? new List<ProjectMeetingRole>();
}

<div class="float-right smallMarginBottom">
    <input type="button" onclick="@string.Format("location.href = '{0}';", this.Url.Action("NewProject"))" value="Opret ny" class="" />
</div>
<table class="tableView">
    <tr>
        @foreach (TableViewHeaderItem item in this.Model.Header.Items)
        {
            <td>
                @Html.Partial("~/Views/_Shared/TableViewHeader.cshtml", item)
            </td>
        }
        <td></td><td></td>
    </tr>
    @if (this.Model != null)
    {
        foreach (ProjectMeeting meeting in this.Model.List)
        {
        <tr>
            <td>@string.Format("{0:dd-MM-yyyy}", meeting.Date)</td>
            <td>
                @meeting.Name
            </td>
            <td>
                @if(meeting.Status.StatusType == ProjectMeetingStatusType.NotStarted)
                {
                    <label>Ikke påbegyndt</label>
                }
                else if(meeting.Status.StatusType == ProjectMeetingStatusType.Started)
                {
                    <label>Påbegyndt</label>
                }
                else if(meeting.Status.StatusType == ProjectMeetingStatusType.Completed)
                {
                    <label>Færdigt</label>
                }
            </td>
            <td>
                @if (meeting.Status.Roles != null && meeting.Status.Roles.Any())
                {
                    foreach(var role in roles.Where(x => meeting.Status.Roles.Contains(x.ID)).OrderBy(x => x.Name) )
                    {
                        @role.Name
                        <br />
                    }
                }
            </td>
            <td>
                <a href="@Url.Action("UpdateProject", new { @Id = meeting.ID })">
                    <img src="@Url.Content("~/Content/ButtonIcons/tool_blue.png")" alt="Link"/></a>
            </td>
                        <td>
                <a href="@Url.Action("ViewProject", new { @Id = meeting.ID })">
                    <img src="@Url.Content("~/Content/ButtonIcons/notepad_blue.png")" alt="Link"/></a>
            </td>
        </tr>
        }
    }
    <tr>
        @Html.Partial("~/Views/_Shared/PagingArrows.cshtml", 
            Website.Models.Styling.PagingArrows.GetPagingArrowsFromHeader("Index", 2, this.Model)
        )
    </tr>
</table>
